<?php

namespace common\models\shop;

use Yii;

/**
 * This is the model class for table "shop_raising_order".
 *
 * @property string $id
 * @property string $pigno
 * @property integer $pigid
 * @property integer $userid
 * @property integer $createtime
 * @property integer $status
 * @property string $price
 * @property integer $paytime
 * @property string $name
 * @property string $phone
 * @property string $remark
 * @property string $ordersn
 * @property string $transid
 * @property string $pigprice
 */
class ShopRaisingOrder extends \yii\db\ActiveRecord
{



    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '认养订单',      //用于修改了什么的显示
        'mainfield' => 'ordersn',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];

    //-2支付失败  -1取消状态，0普通状态，1为已付款，2订单完结(已评价)
    const STATUS_PAYFAIL = -2;
    const STATUS_CANCAL = -1;
    const STATUS_MANAL = 0;
    const STATUS_PAY = 1;
    const STATUS_FINISH = 2;
    const STATUS_REFOUND = 3;
    const STATUS_REFOUND_PASS = 4;
    const STATUS_REFOUND_NOPASS = 5;
    public static $statues = [
        self::STATUS_PAYFAIL => '支付失败',
        self::STATUS_CANCAL => '已取消',
        self::STATUS_MANAL => '待支付',
        self::STATUS_PAY => '已付款',
        self::STATUS_FINISH => '已完成',
        self::STATUS_REFOUND => '申请退款',
        self::STATUS_REFOUND_PASS => '退款审核通过',
        self::STATUS_REFOUND_NOPASS => '申请退款不通过',
    ];


    const WECHAT_PAY = 1;
    const NO_PAY = 0;
    public static $paytype = [
        self::WECHAT_PAY => '微信支付',
        self::NO_PAY => '未支付',
    ];


    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shop_raising_order';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['status', 'price', 'name', 'phone', 'remark', 'ordersn'], 'required'],
            [['pigid', 'userid', 'createtime', 'status', 'paytime','paytype','wanttime'], 'integer'],
            [['price', 'pigprice'], 'number'],
            [['pigno'], 'string', 'max' => 50],
            [['name'], 'string', 'max' => 20],
            [['phone'], 'string', 'max' => 15],
            [['pigvariety'], 'string', 'max' => 30],
            [['remark'], 'string', 'max' => 200],
            [['paydetail','refundfail_remark'], 'string', 'max' => 1500],
            [['ordersn', 'transid','address'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'pigno' => '仔猪编号',
            'pigid' => '仔猪id',
            'userid' => '下单人id',
            'createtime' => '下单时间',
            'status' => '订单状态',
            'price' => '实际支付价格',
            'paytime' => '支付时间',
            'name' => '下单人',
            'phone' => '下单人电话',
            'remark' => '订单备注',
            'ordersn' => '订单sn',
            'transid' => '支付流水',
            'pigprice' => '仔猪价格',
            'paydetail'=> '支付详情',
            'pigvariety' => '仔猪品种',
            'paytype' => '支付方式',
            'refundfail_remark' => '退款审核失败原因',
            'address' => '收货地址',
            'wanttime' => '期望收货时间',
        ];
    }
}
